<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:hftl="http://hftl.org" xmlns:hf="http://java.sun.com/jsf/composite/tags"
	xmlns:c="http://java.sun.com/jsp/jstl/core" template="../templates/template.xhtml">

	<ui:define name="metadata">
		<f:metadata>
			<f:viewParam name="edit" rendered="#{sessionPreferences.editAllowed}" value="#{accountBean.edit}" />
			<f:viewParam name="objectId" value="#{accountBean.objectId}" />
		</f:metadata>
	</ui:define>

	<ui:param name="pageTitle" value="#{messages['account.page.title']}" />
	<ui:define name="content">
	
		<hf:formPanel id="formPanel" label="#{messages['account.page.panel']}" backingBean="#{accountBean}" >
			
			<!-- Simple fields like numbers, strings, dates etc only needs field name provided. -->
			<hf:formField label="#{messages['account.accountNumber']}" field="accountNumber" required="true" />
			<hf:formField label="#{messages['account.active']}" field="active" isMessage="true" />
			<hf:formField label="#{messages['account.openingDate']}" field="openingDate" />
			
			<!-- If field is another entity it needs childField. If we want popup selection - popup parameter must be set to true and popup component present out of this form. -->
			<hf:formEntityField id="customer" label="#{messages['account.customer']}" field="customer" childField="name" popup="true" />
			
			<!-- when entity field contains list of elements we provide which fields from those elements to show with format: label,fieldName,'msg'(optional this is variable to tell 
				if value of fieldName should be translated) then semicolon (;) then if needed describe another field. In this example operationType is enum and its elements has translation so we add 'msg' at the end. -->
			<hf:formField label="#{messages['account.operations']}" field="operations"
				showFields="operation.operationName,operationName;operation.amount,amount;operation.operationType,operationType,msg;" />
		
		</hf:formPanel>
		
		<hftl:entityPopup id="customersPopup" header="#{messages['customer.search']}" updateField=":formPanel:formId:customer:customer" selection="#{accountBean.entity.customer}"
			backingBean="#{customerBean}" searchField1Label="#{messages['customer.name']}" searchField1="name" column1Label="#{messages['customer.name']}" column1="name" 
			column2Label="#{messages['customer.email']}" column2="email" />

	</ui:define>
</ui:composition>
